<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'name' => 'required|max:255|regex:/^[a-zA-Z][a-zA-Z0-9]+/',
            'display_name' => 'required|max:255',
            'description' => 'required|max:255'
        ];

        return $rules;
    }

    public function messages()
    {
        return [
            'name.required' => '角色Name不能为空',
            'name.regex' => '角色Name必须是字母与数字,且字母开头',
            'display_name.required' => '显示名称不能为空',
            'description.required' => "角色描述不能为空"
        ];
    }
}
